const fs = require('fs');
const zlib = require('zlib');

// 创建可读流，并通过管道把数据写入压缩文件中
const readable = fs.createReadStream('input.txt');
const writable = fs.createWriteStream('output.txt.gz');
const gzip = zlib.createGzip();

readable.pipe(gzip).pipe(writable);

console.log('文件压缩完成');
